home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 7 / BBS in a Box - Macintosh - Volume VII (BBS in a Box) (January 1993).iso / Files / Art / I / Imagic.cpt / External Functions / Grid Source / XFunctionsMain.c < prev   
Text File  |  1992-03-04  |  2KB  |  65 lines

  1. /**************************************************************************************************
  2.  *                    XFunctionsMain.c
  3.  *
  4.  *            Written By: Brian Powell
  5.  *            (c) 1991, All Rights Reserved.
  6.  *            
  7.  *            This contains the main function for the external modules.  Whenever Imagic makes a
  8.  *            call to an external function, this is the function that gets called.  This then 
  9.  *            interprets the type of call that Imagic made and calls the correct function from there.
  10.  *
  11.  *************************************************************************************************/
  12.  
  13. /* Include these files.
  14.  */
  15. #include "XFunctionNumbers.h"
  16. #include "XFunctions.h"
  17.  
  18. ProcPtr         (*(**functions)());
  19.  
  20. /* We don't want the file SetUpA4.h at the top of the program because this file generates code
  21.  * that we don't want put into our program.  Therefore, it needs to go down here so that it will
  22.  * not stick code into our file. */
  23.  
  24. #include <SetUpA4.h>
  25.  
  26. pascal OSErr main (message, Functions, parameters)
  27.     int message;
  28.     ProcPtr (*(**Functions)());
  29.     InitStruct *parameters;
  30. {
  31.     OSErr Error = noErr;
  32.  
  33.     /* Set up register A4 so that we can use global variables correctly.
  34.      * See the Think C Users Manual, page 87 for more details.
  35.      * (The 1989 version of the Think C 4.0 manual).  
  36.      * ---> Addendum <---
  37.      * For Think C 5.0, see page 119 of the Think C 5.0 User's Manual. 
  38.      */
  39.     RememberA0();
  40.     SetUpA4();
  41.  
  42.     functions = Functions;
  43.     switch (message) {
  44.         case INITIALIZE:
  45.             Error=Initialize(parameters);
  46.             parameters->Version = EXTERNAL_FUNCTION_LIBRARY_VERSION_NUM; 
  47.             break;
  48.         case MENU_ITEM:
  49.             Error=ExecuteMenu();
  50.             break;
  51.         case SHUT_DOWN:
  52.             Error=Exit();
  53.             break;
  54.     }
  55.  
  56.     /* Restore register A4 to it's original value.
  57.      */
  58.     RestoreA4();
  59.  
  60.     /* Return the error code (if any).
  61.      */
  62.     return Error;
  63. }
  64.  
  65.